﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace ACL.Comm
{
     [DataContract]
    public  class Agent
    {      
 

        [DataMember]
        public string Id;

         [DataMember]
        public string Name;
        
        [DataMember]
        public string Comments;

        [DataMember]
        public List<string> Skills;

        [DataMember]
        public DateTime TimeSubmited;



         /// <summary>
         /// Check if two agents are equals this disregards timesubmitted and looks at the ID only
         /// </summary>
         /// <param name="first"></param>
         /// <param name="second"></param>
         /// <returns></returns>
        public  bool Equals(Agent agent)
        {
            return (agent.Id == this.Id);
        }

         /// <summary>
         /// This check if agents have skills in common
         /// </summary>
         /// <param name="first"></param>
         /// <param name="second"></param>
         /// <returns></returns>
        public List<string> CompareSkills(Agent first, Agent second)
        {
            List<string> matchingSkills = new List<string>();

            foreach (var skill in first.Skills)
            {

                if(second.Skills.Where(b => b == skill).Count()>0)
                matchingSkills.Add(second.Skills.Where(b => b == skill).FirstOrDefault());
                                
            }
            return matchingSkills;
        }
    
    }
}
